<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<%@include file="/WEB-INF/view/common/common.jsp" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="${ctx}/resources/mallcss/initcss.css" rel="stylesheet">
    <link href="${ctx}/resources/mallcss/common.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style type="text/css">

    </style>
    <title>奖金提现</title>
    <head>
<body style="background: rgb(232, 232, 232);">
<div>
    <p style="font-size: 18px; text-align: center;margin-top: 10px">申请提现</p>
</div>
<hr/>
<div>
    <div style="text-align: center">
        <p style="font-size: 12px;color: #7d0000">提现介绍：</p>
        <p style="font-size: 12px;color: #7d0000">1.100起提</p>
        <p style="font-size: 12px;color: #7d0000">2.提现银行卡一次绑定，不能修改。修改需要联系管理员</p>
    </div>

    <div style="text-align: center;padding-top: 50px;">

        <form>

            <c:if test="${Username == null}">
                <p>用户姓名：<input id="username" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" placeholder="例如：周杰" /></p><br/>
            </c:if>
            <c:if test="${Username != null}">
                <p>用户姓名：<input id="username1" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" value="${Username}" readonly="readonly" /></p><br/>
            </c:if>


            <c:if test="${BankName == null}">
                <p>银行名称：<input id="bankName" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" placeholder="例如：工商银行" /></p><br/>
            </c:if>
            <c:if test="${BankName != null}">
                <p>银行名称：<input id="bankName1" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" value="${BankName}" readonly="readonly" /></p><br/>
            </c:if>


            <c:if test="${CardNumber == null}">
                <p>银行卡号：<input id="bankNumber" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" placeholder="例如：6222024444452011111" /></p><br/>
            </c:if>
            <c:if test="${CardNumber != null}">
                <p>银行卡号：<input id="bankNumber1" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" value="${CardNumber}" readonly="readonly" /></p><br/>
            </c:if>


            <c:if test="${SubBranch == null}">
                <p>支行信息：<input id="subBranch" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" placeholder="例如：大学城支行" /></p><br/>
            </c:if>
            <c:if test="${SubBranch != null}">
                <p>支行信息：<input id="subBranch1" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" value="${SubBranch}" readonly="readonly" /></p><br/>
            </c:if>


            <c:if test="${Phone == null}">
                <p>预留手机：<input id="phone" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" placeholder="例如：15674102586" /></p><br/>
            </c:if>
            <c:if test="${Phone != null}">
                <p>预留手机：<input id="phone1" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" value="${Phone}" readonly="readonly" /></p><br/>
            </c:if>

            <p>提现金额：<input id="bankMoney" style="padding-top:6px;width:220px;line-height: 20px;padding-left: 6px;" type="text" placeholder="例如：10000" /></p><br/>

            <button style="width: 100px;font-size: 16px;line-height: 26px;" id="btnTX"><strong>确认提现</strong></button>

        </form>
    </div>
</div>
<script type="text/javascript" src="${ctx}/resources/lottery/js/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="http://apps.bdimg.com/libs/jquery-qrcode/1.0.0/jquery.qrcode.min.js"></script>
</body>
<script>
    $(function () {
        $("#btnTX").on('click', function () {

            var bankMoney = document.getElementById("bankMoney").value;

            if( ${Username == null}){
                var username1 = "";
            }else{
                var username1 = "${Username}";
            }
            if( ${BankName == null}){
                var bankName1 = "";
            }else{
                var bankName1 = "${BankName}";
            }
            if( ${CardNumber == null}){
                var cardNumber1 = "";
            }else{
                var cardNumber1 = "${CardNumber}";
            }
            if( ${SubBranch == null}){
                var subBranch1 = "";
            }else{
                var subBranch1 = "${SubBranch}";
            }
            if( ${Phone == null}){
                var phone1 = "";
            }else{
                var phone1 = "${Phone}";
            }

            var zhi = 1;

            if((username1 == "" && username1.length == 0) || (cardNumber1 == "" && cardNumber1.length == 0)){
                var username = document.getElementById("username").value;
                var bankName = document.getElementById("bankName").value;
                var bankNumber = document.getElementById("bankNumber").value;
                var subBranch = document.getElementById("subBranch").value;
                var phone = document.getElementById("phone").value;
                if(username == "" && username.length == 0){
                    alert("请输入用户姓名!");
                }else{
                    if(bankNumber == "" && bankNumber.length == 0){
                        alert("请输入银行卡号!");
                    }else {
                        if(bankName == "" && bankName.length == 0){
                            alert("请输入银行名称!");
                        }else{
                            if(subBranch == "" && subBranch.length == 0){
                                alert("请输入支行信息!");
                            }else{
                                if(phone == "" && phone.length == 0){
                                    alert("请输入预留手机号!");
                                }else{
                                    if(bankMoney == "" && bankMoney.length == 0){
                                        alert("请输入提现金额!");
                                    }else{
                                        if(bankMoney < 100){
                                            alert("提现金额不能小于100!");
                                        }else{
                                            var bonus= ${MyVoucherBalance};
                                            if(bankMoney > bonus){
                                                alert("您目前最多能提现："+ bonus +"元!");
                                            }else{
                                                zhi = 10;
                                                var url = "<c:url value="/mobile/cashWithdrawal.json" />";
                                                if (confirm("温馨提示：确认提现后无法撤销，请谨慎合理操作。确认提现吗？")) {
                                                    $.ajax({
                                                        url: url,
                                                        type: 'post',
                                                        data: {
                                                            username : username,
                                                            cardNumber : bankNumber,
                                                            bankName : bankName,
                                                            subBranch : subBranch,
                                                            phone : phone,
                                                            amountMoney : bankMoney,
                                                            zhi : zhi
                                                        },
                                                        dataType: 'json',
                                                        success: function (data) {
                                                            <%--if(data.flag == "0"){--%>
                                                                <%--alert("提现成功!");--%>
                                                                <%--window.location.href = "<c:url value="/mobile/cashRecord.html"/>";--%>
                                                            <%--}else {--%>
                                                                <%--alert("提现失败!请核对数据后再操作或联系管理员。");--%>
                                                            <%--}--%>
                                                        }
                                                    });
                                                }
                                                alert("提现成功！");
                                                window.location.href="<c:url value="/mobile/cashRecord.html"/>";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }else{
                if(bankMoney == "" && bankMoney.length == 0){
                    alert("请输入提现金额!");
                }else{
                    if(bankMoney < 100){
                        alert("提现金额不能小于100!");
                    }else{
                        var bonus= ${MyVoucherBalance};
                        if(bankMoney > bonus){
                            alert("您目前最多能提现："+ bonus +"元!");
                        }else{
                            zhi = 20;
                            var url = "<c:url value="/mobile/cashWithdrawal.json" />";
                            if (confirm("温馨提示：确认提现后无法撤销，请谨慎合理操作。确认提现吗？")) {
                                $.ajax({
                                    url: url,
                                    type: 'post',
                                    data: {
                                        username : username1,
                                        cardNumber : cardNumber1,
                                        bankName : bankName1,
                                        subBranch : subBranch1,
                                        phone : phone1,
                                        amountMoney : bankMoney,
                                        zhi : zhi
                                    },
                                    dataType: 'json',
                                    success: function (data) {
                                        <%--if(data.flag == "0"){--%>
                                            <%--alert("提现成功!");--%>
                                            <%--window.location.href = "<c:url value="/mobile/cashRecord.html"/>";--%>
                                        <%--}else {--%>
                                            <%--alert("提现失败!请核对数据后再操作或联系管理员。");--%>
                                        <%--}--%>
                                    }
                                });
                            }
                            alert("提现成功！");
                            window.location.href="<c:url value="/mobile/cashRecord.html"/>";
                        }
                    }
                }
            }
        });
    });
</script>
</html>
